﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VipCo.Data;
using VipCo.Entities;

public partial class Controls_QuangcaoRightControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HienthiQuangcao();
        }
    }

    protected void HienthiQuangcao()
    {
        int totalRows = 0;
        string whereClauseNqc = "TrangThai = 1 and Ten like N'%" + Common.quangcao300x500 + "%'";
        TList<NhomQuangCao> tlistNhomQc = DataRepository.NhomQuangCaoProvider.GetPaged(whereClauseNqc, "Id DESC", 0, 1, out totalRows);
        if (tlistNhomQc.Count > 0)
        {
            string whereClause = "TrangThai = 1 and IdQuangCao = " + tlistNhomQc[0].Id;
            TList<QuangCaoHome> tlistQcHome = DataRepository.QuangCaoHomeProvider.GetPaged(whereClause, "Id DESC", 0, 3,
                out totalRows);
            string shtml = "";
            if (tlistQcHome.Count > 0)
            {
                foreach (var qchome in tlistQcHome)
                {
                    shtml += "<div class=\"quang-cao-element\">";
                    shtml += "<div class=\"img-qc\">";
                    shtml += "<a href='" + qchome.MaCode + "' target=\"_blank\">";
                    shtml += "<img tooltip='" + qchome.Ten + "' src='" + "Upload/QuangCao/" + qchome.AnhDaiDien + "' alt='" + qchome.Ten + "' />";
                    shtml += "</a>";
                    shtml += "</div>";
                    shtml += "</div>";

                    litQcright.Text = shtml;
                }
            }
        }

    }
}